<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
    	<meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
		
		<link rel="stylesheet" href="libs/bootstrap/css/bootstrap.min.css"/>
		
		<script src="libs/jquery.min.js"></script>
		<script src="libs/bootstrap/js/bootstrap.min.js"></script>
		
		<title>登录</title>
		
	</head>
	<body>
		
		<nav class="navbar navbar-inverse" role="navigation">
		  	<div class="container">
		    <!-- Brand and toggle get grouped for better mobile display -->
			    <div class="navbar-header">
			      	<a class="navbar-brand" href="#">智游教育</a>
			    </div>
			
			    <!-- Collect the nav links, forms, and other content for toggling -->
			    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
			      	<ul class="nav navbar-nav navbar-right">
				        <li><a href="/regist.html"><span class="glyphicon glyphicon-registration-mark"></span>注册</a></li>
			      	</ul>
			    </div><!-- /.navbar-collapse -->
		  	</div><!-- /.container-fluid -->
		</nav>
		
		
		<div class="container">
			
			<form role="form" id="login-form">
				
				<div class="form-group">
					<label for="">账号</label>
					<input class="form-control" type="text" name="account" autocomplete="off" required placeholder="数字、字母、下划线，1到6位"/>
				</div>
				
				<div class="form-group">
					<label for="">密码</label>
					<input class="form-control" type="password" name="psw" required/>
				</div>
				
				
				<button type="submit" class="btn btn-success form-control "/>登录</button>
				
			</form>
			
		</div>
		
		<script>
			
			$("#login-form").submit(function(e){
				e.preventDefault();
				if(!$("[name=account]").val().match(/^\w{1,6}$/)){
					alert("账号格式不合符要求");
					return;
				}

				var data = $("#login-form").serialize();
				
				$.post("/login-api",data,function(resData){
					alert(resData.msg);
					if(resData.err == 0){
						location.href = "/";
					}
				});
				
			});
			
		</script>
		
	</body>
</html>
